package com.iterator.controller.wechat.lyh;

import com.iterator.bean.web.lyh.utils.BaseRespVO;
import com.iterator.bean.web.wy.storage.Storage;
import com.iterator.service.wechat.lyh.WxStorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("wx/storage")
public class WxStorageController {

    @Autowired
    WxStorageService wxStorageService;

    @RequestMapping("upload")
    public BaseRespVO upload(MultipartFile file, HttpServletRequest request){
        Storage storage = wxStorageService.create(file,request);
        if (storage != null) {
            return BaseRespVO.ok(storage);
        }
        return BaseRespVO.fail("图片上传失败");
    }
}
